/**
 * Copyright(c) ${copyrightYear} ${company}
 * All rights reserved.
 * Created on ${date}
 */
package ${package}.service.user;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import ${package}.entity.UserEntity;
import ${package}.Struts2SpringContext;
import ${package}.vo.UserVO;
import ${package}.BaseService;
import ${package}.dao.UserDAO;

/**
 * 用户service
 * 
 * @author ${author}
 */
@SuppressWarnings("unused")
@Service("userService")
public class UserService extends BaseService {
    /**
     * 用户DAO
     */
    @Resource
    private UserDAO userDAO;

    /**
     * 注销
     * 
     * @param userVO
     * @return
     * @throws Exception
     *             所有异常
     */
    public void logout(Struts2SpringContext<UserVO> context) throws Exception {
    }

    /**
     * 登陆
     * 
     * @return
     * @throws Exception
     *             所有异常
     */
    public void login(Struts2SpringContext<UserVO> context) throws Exception {
    }

    /**
     * 注册
     * 
     * @return
     * @throws Exception
     *             所有异常
     */
    public void addUser(Struts2SpringContext<UserVO> context) throws Exception {
		UserVO userVO = context.getVo();
		UserEntity userEntity = userDAO
				.findUserByUsername(userVO.getUsername());
		if (userEntity != null) {
			context.addErrorMsg("用户已经存在");
			return;
		}
		userEntity = new UserEntity();
		BeanUtils.copyProperties(userVO, userEntity);
		userDAO.insert(userEntity);
    }

    /**
     * @param context
     * @throws Exception
     *             所有异常 
     */
    public void query(Struts2SpringContext<UserVO> context) throws Exception {
        // TODO Auto-generated method stub

    }
}
